﻿@{
    ViewBag.Title = "受理事件基础信息";
    Layout = "~/Areas/IM/Views/Shared/_Layout.cshtml";
}
<script src="~/Content/layer-v3.1.1/layer/layer.js"></script>
@section scripts{
    <script type="text/javascript">
    var timetitle;
    var subLayer; //add2021-07-02 plq
    $(document).ready(function () {
        getAcceptEventInfo();
        getAlarmEventInfo();
        telRecordGrid();
        newTaskAccordion();
        $.setDivOnly("#AETInfo");//
        BindCombobox();
        BindAcceptCombobox();
    });
    $(window).resize(function () {
        $.setDivOnly("#divIndex");
    });

    //电话录音的表格
    function telRecordGrid() {
        $('#telRecord').datagrid({
            width: '98%',
            height: '98%',
            fitColumns: true,
            singleSelect: true,
            loadMsg: '数据加载中请稍后……',
            url: '@Url.Content("~/DD/AcceptEvent/GetAlarmCalls")',
            striped: true,
            pagination: true,//启用分页，默认每页10行
            rownumbers: true,//显示页码，默认 提供 10 - 50 的页容量选择下拉框
            pageSize: 15,//设置 页容量5为
            pageList: [10, 15, 20],//设置 页容量下拉框
            queryParams: {
                EventCode: $("#ECID").val(),
                AcceptOrder: $("#ACOrderID").val()
            },
            frozenColumns: [[
               { field: "EventCode", title: "事件编码", width: '11%', align: "center" },
                //{ field: "OrderNumber", title: "受理序号", width: '6%', align: "center" },
               { field: "CallType", title: "通话类型", width: '7%', align: "center" },
               { field: "CallNumber", title: "主叫号码", width: '8%', align: "center" },
               { field: "CallTime", title: "通话时刻", width: '10%', align: "center", formatter: $.formatTime },
               { field: "EndCallTime", title: "结束时刻", width: '10%', align: "center", formatter: $.formatTime },
               { field: "TeskCode", title: "台号", width: '6%', align: "center" },
               { field: "DispatcherName", title: "调度员", width: '8%', align: "center" },
               { field: "RecordNumber", title: "录音号", width: '12%', align: "center" },
               {
                   field: "IfCallOut", title: "是否呼出", width: '7%', align: "center",
                   formatter: function (value, row, index) {
                       if (row.IfCallOut == true) {
                           return "呼出";
                       } else {
                           return "呼入";
                       }
                   }
               },
               {
                   title: '录音播放', field: 'Record', width: '5%', align: "center", sortable: false,
                   formatter: function (value, row, index) {
                       if (row.RecordNumber) {
                           var baseUrl = '@Url.Content("~/DD/AcceptEvent/MediaPlayer")';
                           return "<img id='message' width='20px' style='cursor: pointer; vertical-align:middle' src='" + '@Url.Content("~/Images/main/mediaplayer.png")' +
                           "' onclick =\"openNewPage('diag1','" + baseUrl + '?code=' + row.RecordNumber + '&buildTime=' + dateToTime2(row.CallTime) + "','电话录音',650,250)\"/>";
                       } else {
                           return "";
                       }
                   }
               },
               //add2021-02-07 plq 录音下载
                   {
                       title: '录音下载', field: 'Download', width: '5%', align: "center", sortable: false,
                       formatter: function (value, row, index) {
                           if (row.RecordNumber) {
                               return "<img id='message' width='14px' style='cursor: pointer; vertical-align:middle' src='" + '@Url.Content("~/images/main/download.png")' +
                                       "' onclick =\"downloadRecord('" + row.RecordNumber + "','" + dateToTime2(row.CallTime) + "')\"/>";
                           } else {
                               return "";
                           }
                       }
                   },

            ]],
            rowStyler: function (index, row) {
                if (row.IfCallOut == true) {
                    return 'color:red';
                }
            }
        });
    }

    //录音下载 add2021-07-02 plq
    function downloadRecord(RecordNumber, CallTime) {
        //获取录音文件路径
        $.ajax({
            url: '@Url.Content("~/DD/AcceptEvent/RecordingDownload")',
            data: {
                RecordNumber: RecordNumber,
                CallTime: CallTime,
            },
            success: function (data) {  //动态设置录音文件的路径
                //console.log(data);
                if (data.result) {
                    var filePath = data.data;
                    //console.log(filePath);
                    //var index = filePath.lastIndexOf("\/");
                    //fileName = filePath.substring(index + 1); //文件路径中提取文件名
                    window.location = '@Url.Content("~/DD/AcceptEvent/DownloadFile?strFileName=")' + RecordNumber + "&strFilePath=" + filePath;
                    //$.messager.alert('提示', '录音下载成功，文件保存为：' + data.data);
                }
                else {
                    $.messager.alert('提示', '录音下载失败');
                }
            }
        });
    }

    //打开弹层页面
    function openNewPage(ID, arg, title, x, y) {
        subLayer = layer.open({ //弹层调用方式，都会返回一个index
            type: 2,
            title: title,
            maxmin: false,
            shadeClose: false, //点击遮罩关闭层
            area: [x + 'px', y + 'px'],
            //content: "../" + arg,
            content: arg,
            cancel: function () { //右上角关闭按钮触发的回调
                //location.reload();
            }
        });
    }
    //关闭弹层页面并重新查询数据
    function autoclick() {
        layer.close(subLayer);
        lnk = document.getElementById("btnSearch");
        lnk.click();
    }
    //关闭弹层页面并重载页面
    function closeNewPage() {
        layer.close(subLayer);
        location.reload();
    }
    //只关闭弹层页面
    function closePage() {
        layer.close(subLayer);
    }

    //获取事件信息
    function getAlarmEventInfo() {
        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/AcceptEvent/GetAlarmEventInfo")',
            data:
                {
                    EventCode: $("#ECID").val(),
                    AcceptOrder: $("#ACOrderID").val()
                },
            dataType: "json",
            success: function (jsData) {
                $('#EventCode').html(jsData.PLInfo.EventCode);
                if (jsData.PLInfo.IsFinish == true) { $('#IsFinish').html("是"); }
                else { $('#IsFinish').html("否"); }
                if (jsData.PLInfo.IsPlaceOrder == true) { $('#IsPlaceOrder').html("是"); }
                else { $('#IsPlaceOrder').html("否"); }
                $('#EventType').html(jsData.PLInfo.EventType);
                $('#EventSource').html(jsData.PLInfo.EventSource);
                $('#CenterName').html(jsData.PLInfo.CenterName);
                $('#EvetnName').html(jsData.PLInfo.EvetnName);
                $('#FirstAlarmCall').html(jsData.PLInfo.FirstAlarmCall);
                if (jsData.PLInfo.IsTest == true) { $('#IsTest').html("是"); }
                else { $('#IsTest').html("否"); }
                var fFirstAcceptTime = $.formatTime(jsData.PLInfo.FirstAcceptTime);
                $('#FirstAcceptTime').html(fFirstAcceptTime);
                $('#FirstDisptcherName').html(jsData.PLInfo.FirstDisptcherName);
                $('#AcceptCount').html(jsData.PLInfo.AcceptCount);
                $('#FirstSendAmbTime').html($.formatTime(jsData.PLInfo.FirstSendAmbTime));
                $('#IllState').html(jsData.PLInfo.IllStateName);
                $('#TieUpDeskCode').html(jsData.PLInfo.TieUpDeskCode);
                $('#CancelAcceptCount').html(jsData.PLInfo.CancelAcceptCount);
                $('#TransactTaskCount').html(jsData.PLInfo.TransactTaskCount);
                $('#BreakTaskCount').html(jsData.PLInfo.BreakTaskCount);

                if (jsData.PLInfo.IsHangUp == true) { $('#IsHangUp').html("是"); }
                else { $('#IsHangUp').html("否"); }
                $('#HangUpTime').html($.formatTime(jsData.PLInfo.HangUpTime));
                $('#BespeakTime').html($.formatTime(jsData.PLInfo.BespeakTime));
                if (jsData.PLInfo.IsLabel == true) { $('#IsLabel').html("是"); }
                else { $('#IsLabel').html("否"); }
                $('#XYPosition').html(jsData.PLInfo.X + ',' + jsData.PLInfo.Y);
                $('#Area').html(jsData.PLInfo.Area);

                $('#NonceTransactTaskCount').html(jsData.PLInfo.NonceTransactTaskCount);
                $('#AccidentType').html(jsData.PLInfo.AccidentType);
                $('#AccidentLevel').html(jsData.PLInfo.AccidentLevel);

                //if (jsData.PLInfo.AccidentLevelCode == -1) {
                //    $('#AccidentLevel').html('');
                //}
                //else {
                //    $('#AccidentLevel').html(jsData.PLInfo.AccidentLevel);
                //}

                //修改事件信息
                if ('@ViewData["RoleEventPermissionInsert"]' == "Insert") {
                    //$('#EventEdit').show();
                    $('#EventEdit').hide(); //add2021-04-22 plq 郊区不允许修改
                    $('#EventCode').val(jsData.PLInfo.EventCode);
                    $('#EEvetnName').textbox('setValue', jsData.PLInfo.EvetnName);
                    $('#EArea').combobox('setValue', jsData.PLInfo.Area);

                    //if (jsData.PLInfo.EventSource != "") {
                    //    $('#EEventSourceCode').combobox('setValue', jsData.PLInfo.EventSourceCode);
                    //}
                    //else {
                    //}
                    $('#EEventSourceCode').combobox('setValue', jsData.PLInfo.EventSourceCode);

                    if (jsData.PLInfo.AccidentLevelCode == -1) {
                        //事故等级编码取-1时，“事故等级”为“”
                    }
                    else {
                        $('#EAccidentLevelCode').combobox('setValue', jsData.PLInfo.AccidentLevelCode);
                    }

                    //if (jsData.PLInfo.AccidentType != "") {
                    //    $('#EAccidentTypeCode').combobox('setValue', jsData.PLInfo.AccidentTypeCode);
                    //}
                    //else {
                    //}
                    $('#EAccidentTypeCode').combobox('setValue', jsData.PLInfo.AccidentTypeCode);
                }
                else { $('#EventEdit').hide(); }
            }
        });
    }
    //修改事件信息调用字典表 2016-10-24
    function BindCombobox() {
        //区域
        $('#EArea').combobox({
            url: '@Url.Content("~/BB/AllDictionary/GetArea")',
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            onChange: function (n, o) {
            }
        });
        //事故来源
        $('#EEventSourceCode').combobox({
            url: '@Url.Content("~/BB/AllDictionary/GetEventSource")',
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            onChange: function (n, o) {
            }
        });
        //事故等级
        $('#EAccidentLevelCode').combobox({
            url: '@Url.Content("~/BB/AllDictionary/GetAccidentLevel")',
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            onChange: function (n, o) {
            }
        });
        //事故类型
        $('#EAccidentTypeCode').combobox({
            url: '@Url.Content("~/BB/AllDictionary/GetAccidentType")',
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            onChange: function (n, o) {
            }
        });
    }
    //保存修改的事件信息，查看事件信息修改的痕迹 2016-10-25
    function submitEditForm() {
        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/AcceptEvent/UpdateEvent")',
            data:
                {
                    EventCode: $('#EventCode').val(),
                    EvetnName: $('#EEvetnName').textbox('getText'),
                    Area: $('#EArea').combobox('getText'),
                    EventSourceCode: $('#EEventSourceCode').combobox('getValue'),
                    AccidentLevelCode: $('#EAccidentLevelCode').combobox('getValue') == "" ? -1 : $('#EAccidentLevelCode').combobox('getValue'),
                    AccidentTypeCode: $('#EAccidentTypeCode').combobox('getValue')
                },
            dataType: "json",
            success: function (jsData) {
                if (jsData.IsSuccess) {
                    $.messager.alert('提示', jsData.Message, 'info', function () {
                        location.reload();
                        //closeDialog();
                    });
                }
                else {
                    $.messager.alert('提示', jsData.Message, 'info', function () {
                    });
                }
            }

        });
    };
    //关闭弹层
    function closeDialogLookCrack() {
        $('#LookCrack').window('close');
    }
    //显示事件信息修改痕迹
    function ViewEventModify() {
        $('#CrackList').datagrid({
            title: '修改记录列表',
            width: '99%',
            height: 460,
            nowrap: true,
            autoRowHeight: true,
            striped: true,
            collapsible: true,
            url: '@Url.Content("~/AcceptEvent/GetEventCrackInfos?EventCode=")' + '@ViewBag.EventCode',
            //sortName: 'ChanShengShiKe',
            //sortOrder: 'desc',
            remoteSort: false,
            singleSelect: true,
            frozenColumns: [[
                { title: '修改时间', field: 'StringOperateTime', width: 120, sortable: true },
                { title: '修改人', field: 'OperatorName', width: 70, sortable: false },
                { title: '修改项目', field: 'TypeName', width: 80, sortable: false },
                { title: '修改前内容', field: 'OriginContent', width: 160, sortable: false },
                { title: '修改后内容', field: 'NewContent', width: 160, sortable: false },
                { title: '事件编码', field: 'EventCode', width: 180, sortable: false }
            ]],
            pagination: true,//启用分页，默认每页10行
            rownumbers: true,//显示页码，默认 提供 10 - 50 的页容量选择下拉框
            pageNumber: 1,
            pageSize: 15,//设置 页容量5为
            pageList: [10, 15, 20]//设置 页容量下拉框

        });
        var p = $('#CrackList').datagrid('getPager');
        $(p).pagination({
            onBeforeRefresh: function () {
            }
        });
        $('#LookCrack').window('open');
    }

    //获取受理详细信息
    function getAcceptEventInfo() {
        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/AcceptEvent/GetAcceptEventInfo")',
            data:
                {
                    EventCode: $("#ECID").val(),
                    AcceptOrder: $("#ACOrderID").val()
                },
            dataType: "json",
            success: function (jsData) {
                $('#Dispatcher').html(jsData.PRInfo.Dispatcher);
                $('#AcceptType').html(jsData.PRInfo.AcceptType);
                $('#DetailReason').html(jsData.PRInfo.DetailReason);
                $('#AlarmTel').html(jsData.PRInfo.AlarmTel);
                $('#HangUpTime').html($.formatTime(jsData.PRInfo.HangUpTime));
                //将日期时间格式化，调动formatTime();
                var fRingTime = $.formatTime(jsData.PRInfo.RingTime);
                $('#RingTime').html(fRingTime);
                var fAcceptBeginTime = $.formatTime(jsData.PRInfo.AcceptBeginTime);
                $('#AcceptBeginTime').html(fAcceptBeginTime);
                var fAcceptEndTime = $.formatTime(jsData.PRInfo.AcceptEndTime);
                $('#AcceptEndTime').html(fAcceptEndTime);
                var fCommandTime = $.formatTime(jsData.PRInfo.CommandTime);
                $('#CommandTime').html(fCommandTime);
                $('#LocalAddr').html(jsData.PRInfo.LocalAddr);
                $('#LocalAddrType').html(jsData.PRInfo.LocalAddrType);
                $('#ACCenterName').html(jsData.PRInfo.CenterName);
                $('#SendAddr').html(jsData.PRInfo.SendAddr);
                $('#SendAddrType').html(jsData.PRInfo.SendAddrType);

                $('#WaitAddr').html(jsData.PRInfo.WaitAddr);
                $('#PatientName').html(jsData.PRInfo.PatientName);
                $('#Sex').html(jsData.PRInfo.Sex);
                $('#Age').html(jsData.PRInfo.Age);
                $('#National').html(jsData.PRInfo.National);
                //if (jsData.PRInfo.Folk == null) { $('#Folk').html("汉族"); }
                //else { $('#Folk').html(jsData.PRInfo.Folk); }
                $('#AlarmReason').html(jsData.PRInfo.AlarmReason);
                $('#IllState').html(jsData.PRInfo.IllState);
                $('#Judge').html(jsData.PRInfo.Judge);
                $('#LinkMan').html(jsData.PRInfo.LinkMan);
                $('#LinkTel').html(jsData.PRInfo.LinkTel);
                $('#Extension').html(jsData.PRInfo.Extension);
                $('#PatientCount').html(jsData.PRInfo.PatientCount);
                //if (jsData.PRInfo.IsNeedLitter)
                //{ $('#IsNeedLitter').html("需要"); }
                //else {
                //    $('#IsNeedLitter').html("不需要");
                //}
                $('#SpecialNeed').html(jsData.PRInfo.SpecialNeed);

                if (jsData.PRInfo.IsLabeled)
                { $('#ACIsLabel').html("是"); }
                else {
                    $('#ACIsLabel').html("否");
                }
                $('#ACXYPosition').html(jsData.PRInfo.X + "，" + jsData.PRInfo.Y);
                //$('#EmergencyFee').html(jsData.PRInfo.EmergencyFee);
                $('#ACRemark').html(jsData.PRInfo.Remark);
                //派车列表调用了换行方法。
                var SendAmbulanceList = "";
                SendAmbulanceList = jsData.PRInfo.AmbulanceList;
                ListHuanHang(SendAmbulanceList);

                //修改受理信息
                if ('@ViewData["RoleEventPermissionInsert"]' == "Insert") {
                    //$('#AcceptEdit').show();
                    $('#AcceptEdit').hide(); //add2021-04-22 plq 郊区不允许修改

                    $('#EventCode').val(jsData.PRInfo.EventCode);

                    $('#EAlarmReason').textbox('setValue', jsData.PRInfo.AlarmReason);
                    $('#EIsNeedLitter').combobox('setValue', jsData.PRInfo.IsNeedLitter);
                    $('#EPatientName').textbox('setValue', jsData.PRInfo.PatientName);
                    $('#ESex').combobox('setText', jsData.PRInfo.Sex);
                    $('#EAge').combobox('setValue', jsData.PRInfo.Age);
                    $('#ENational').combobox('setValue', jsData.PRInfo.National);
                    $('#EFolk').combobox('setValue', jsData.PRInfo.Folk);
                    $('#EJudge').textbox('setValue', jsData.PRInfo.Judge);
                    $('#ELinkMan').textbox('setValue', jsData.PRInfo.LinkMan);
                    $('#ELinkTel').textbox('setValue', jsData.PRInfo.LinkTel);
                    $('#EExtension').textbox('setValue', jsData.PRInfo.Extension);
                    $('#ELocalAddr').textbox('setValue', jsData.PRInfo.LocalAddr);
                    $('#EWaitAddr').textbox('setValue', jsData.PRInfo.WaitAddr);
                    $('#ESendAddr').textbox('setValue', jsData.PRInfo.SendAddr);


                }
                else { $('#AcceptEdit').hide(); }
            }
        });
    }

    //修改受理信息调用字典表 2016-10-28
    function BindAcceptCombobox() {
        //年龄
        $('#EAge').combobox({
            url: '@Url.Content("~/BB/AllDictionary/GetAge")',
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            onChange: function (n, o) {
            }
        });
        //国籍
        $('#ENational').combobox({
            url: '@Url.Content("~/BB/AllDictionary/GetNational")',
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            onChange: function (n, o) {
            }
        });
        @*//民族
            $('#EFolk').combobox({
                url: '@Url.Content("~/BB/AllDictionary/GetFolk")',
                valueField: 'ID',
                textField: 'Name',
                editable: false,
                onChange: function (n, o) {
                }
            });*@
    }

    //保存修改的受理信息，查看受理信息修改的痕迹 2016-10-28
    function submitAcceptEditForm() {
        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/AcceptEvent/UpdateAccept")',
            data:
                {
                    EventCode: $('#EventCode').val(),
                    AlarmReason: $('#EAlarmReason').textbox('getText'),
                    IsNeedLitter: $('#EIsNeedLitter').combobox('getValue'),
                    PatientName: $('#EPatientName').combobox('getText'),
                    Sex: $('#ESex').combobox('getText'),
                    Age: $('#EAge').combobox('getText'),
                    National: $('#ENational').textbox('getText'),
                    //Folk: $('#EFolk').textbox('getText'),
                    Judge: $('#EJudge').textbox('getText'),
                    LinkMan: $('#ELinkMan').textbox('getText'),
                    LinkTel: $('#ELinkTel').textbox('getText'),
                    Extension: $('#EExtension').textbox('getText'),
                    LocalAddr: $('#ELocalAddr').textbox('getText'),
                    WaitAddr: $('#EWaitAddr').textbox('getText'),
                    SendAddr: $('#ESendAddr').textbox('getText')
                },
            dataType: "json",
            success: function (jsData) {
                if (jsData.IsSuccess) {
                    $.messager.alert('提示', jsData.Message, 'info', function () {
                        location.reload();
                        //closeDialog();
                    });
                }
                else {
                    $.messager.alert('提示', jsData.Message, 'info', function () {
                    });
                }
            }

        });
    };
    function closeDialogLookCrack() {
        $('#LookCrack').window('close');
    }
    //显示受理信息修改痕迹
    function ViewAcceptModify() {
        $('#CrackList').datagrid({
            title: '修改记录列表',
            width: '99%',
            height: 460,
            nowrap: true,
            autoRowHeight: true,
            striped: true,
            collapsible: true,
            url: '@Url.Content("~/AcceptEvent/GetAcceptCrackInfos?EventCode=")' + '@ViewBag.EventCode',
            //sortName: 'ChanShengShiKe',
            //sortOrder: 'desc',
            remoteSort: false,
            singleSelect: true,
            frozenColumns: [[
                { title: '修改时间', field: 'StringOperateTime', width: 120, sortable: true },
                { title: '修改人', field: 'OperatorName', width: 70, sortable: false },
                { title: '修改项目', field: 'TypeName', width: 80, sortable: false },
                { title: '修改前内容', field: 'OriginContent', width: 160, sortable: false },
                { title: '修改后内容', field: 'NewContent', width: 160, sortable: false },
                { title: '事件编码', field: 'EventCode', width: 180, sortable: false }
            ]],
            pagination: true,//启用分页，默认每页10行
            rownumbers: true,//显示页码，默认 提供 10 - 50 的页容量选择下拉框
            pageNumber: 1,
            pageSize: 15,//设置 页容量5为
            pageList: [10, 15, 20]//设置 页容量下拉框

        });
        var p = $('#CrackList').datagrid('getPager');
        $(p).pagination({
            onBeforeRefresh: function () {
            }
        });
        $('#LookCrack').window('open');
    }
    //给派车列表的换行，用split(",")将string转换为数组，再循环拼接<br />标签，当模仿foreach 的for in 循环中出现remove时，必须break！
    function ListHuanHang(SendAmbulanceList) {

        var remark = new Array(); var str = ""; var item = "";
        if (SendAmbulanceList != null && SendAmbulanceList) {

            remark = SendAmbulanceList.split(",");
            str = str + remark[0] + '<br />';
            var listStr = new Array();
            listStr = remark[1].split(";");
            for (i in listStr) {
                if (i == "remove") break;
                str = str + listStr[i] + '<br />';
            }
            $('#SendAmbulanceList').html(str);
        }
    }
    function newTaskAccordion() {
        $.setDivOnly("#TaskDetialDIV");


        var taskTimes = $('#IDtaskTimes').val();
        var taskCode = '@ViewBag.taskCodes';//从Contral里传来了任务编码， string,string


        //当出现一个或多个任务时，执行以下内容。
        //根据事件编码和受理序号 判断有几次出车任务，循环添加 easyui-accordion
        if (taskTimes >= 1) {
            $('#TAEInfoTabs').tabs('enableTab', 2);
            $('#TAEInfoTabs').tabs('select', 2);
            var newTaskCode;
            for (var i = 0; i < taskTimes; i++) {

                if (i == 0)                                      //当第一次任务，把逗号截掉
                { newTaskCode = taskCode.substr(0, 20) }
                else {
                    newTaskCode = taskCode.substr((i * 20) + i, 20);//当n次任务时，从第(n*20)+n 的位置截取22个
                    //newTaskCode = '20160201142947040202';
                }
                newTab(newTaskCode);
            }

        }
            //当没有任务时，关闭任务tabs
        else {
            // $('#TAEInfoTabs').tabs('close', 2);
            $('#TAEInfoTabs').tabs('disableTab', 2);
        }
        $.setDivOnly("#TaskDetialDIV");


        $(window).resize(function () {
            $.setDivOnly("#TaskDetialDIV");

        });
    }
    //加一个新的 accordion
    function newTab(newTaskCode) {

        //在accordion的title，根据任务编码 取车辆类型和车辆实际标识
        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/AcceptEvent/GetTaskAmbulance")',
            data:
                {
                    taskCode: newTaskCode
                },
            dataType: "json",
            success: function (jsData) {
                // 类型+实际标识+“任务详情”     效果：普通车 H-25702 任务详情
                timetitle = jsData.PRInfo.AmbulanceType + jsData.PRInfo.RealAmbulanceSign + "任务详情";
                var url = '@Url.Content("~/DD/AcceptEvent/TaskAmbulanceDetial?taskCode=")' + encodeURIComponent(newTaskCode);
                $('#TaskAccordion').accordion('add', {
                    title: timetitle,
                    iconCls: 'icon-custom-cUser',
                    content: newIframe(url),
                    selected: true,
                    animate: true
                });
            }
        });
    }
    //返回一个<iframe></iframe>标签  撑满子页面
    function newIframe(url) {
        var ifrStr = "<iframe   src='" + url + "' style='width:99.5%;height:99.5%;border:1px solid #000;'></iframe>";
        return ifrStr;
    }


    $('#TAEInfoTabs').tabs({
        tools: [{
            text: '事件打印&nbsp;&nbsp;',
            iconCls: 'icon-print',
            handler: function () {
                var tab = $('#TAEInfoTabs').tabs('getSelected');//选中的Tabs
                var tabsindex = $('#TAEInfoTabs').tabs('getTabIndex', tab);//选中的tabs的索引

                if (tabsindex == 2) {
                    var p = $('#TaskAccordion').accordion('getSelected');
                    if (p) {
                        var accordionindex = $('#TaskAccordion').accordion('getPanelIndex', p);//选中的accordion的索引
                    }
                    else { var accordionindex = -1; }
                }
                if (accordionindex >= 0) {
                    if (accordionindex == 0)                                      //当第一次任务，把逗号截掉
                    {
                        var newTaskCode = '@ViewBag.taskCodes'.substring(0, 20)
                        openPrint(tabsindex, newTaskCode);                                  //打开打印连接，传1个索引值,1个任务编码作为参数
                    }
                    else {
                        var newTaskCode = '@ViewBag.taskCodes'.substring((accordionindex * 20) + accordionindex, 20);//当n次任务时，从第(n*22)+n 的位置截取22个
                        openPrint(tabsindex, newTaskCode);
                    }
                }
                else {
                    openPrint(tabsindex, -1);//当任务索引小于0 ，直接传-1，不需打印任务
                }
            }
        }]
    });


    @*//新增保存
        function submitForm() {
            $('#formSubmit').form('submit', {
                url: '@Url.Content("~/PR/Charge/SavePatientCharge")',
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (data) {
                    var jsData = $.parseJSON(data);
                    //$.handleJsonResult(jsData);
                    $.showMsg(jsData.Message, "系统提示", function () { });
                    $('#PrintCharge').linkbutton('enable');
                    $.GID("PrintCharge").style.display = "block";
                    parent.window.opener.bindGrid(); //调用父页面查询方法--刷新
                }
            });
        }*@
    //打印跳转
    function openPrint(type, ptaskcode) {
        var PEventCode = $("#ECID").val();
        var PAcceptOrder = $("#ACOrderID").val();
        var url = '@Url.Content("~/DD/AcceptEventTaskPrint/AETPrint/?PTaskCode=")' + encodeURIComponent(ptaskcode) + '&PEventCode=' + PEventCode + '&PAcceptOrder=' + PAcceptOrder + '&PType=' + type;
        window.open(url);
    }

    //2020-06-10 sr function: 将后台返回的时间戳字符串（“/Date(1547082632000)/”）格式化为easyUI可解析的时间格式--带时分秒
    function dateToTime2(data) {
        if (data) {
            var endIndex = data.indexOf(')');
            var msec = parseInt(data.substring(6, endIndex));
            //console.log(msec);
            var time = new Date(msec);
            return dateFormat2(time);
        }

    }
    //2020-06-10 sr function: 将Date对象获取的时间格式化为easyUI可解析的时间格式---带时分秒
    function dateFormat2(time) {
        var YY = time.getFullYear();
        var MM = (time.getMonth() + 1) < 10 ? ("0" + (time.getMonth() + 1)) : (time.getMonth() + 1);
        var DD = time.getDate() < 10 ? ("0" + time.getDate()) : time.getDate();
        var hh = time.getHours() < 10 ? ("0" + time.getHours()) : time.getHours();
        var mm = time.getMinutes() < 10 ? ("0" + time.getMinutes()) : time.getMinutes();
        var ss = time.getSeconds() < 10 ? ("0" + time.getSeconds()) : time.getSeconds();
        return YY + "-" + MM + "-" + DD + " " + hh + ":" + mm + ":" + ss;
    }
    </script>
}
<script type="text/javascript">

</script>
<form id="formSubmit" method="post">
    <input name="EventCode" type="hidden" id="ECID" value="@ViewBag.EventCode" />
    <input name="AcceptOrder" type="hidden" id="ACOrderID" value="@ViewBag.AcceptOrder" />
    <input name="taskCode" type="hidden" id="IDtaskCode" value="@ViewBag.taskCodes" />
    <input name="taskTimes" type="hidden" id="IDtaskTimes" value="@ViewBag.taskTimes" />
    <div id="AETInfo" style="width: 100%; height: 100%; margin-left: 10px; margin-right: 10px">
        <div class="easyui-tabs" id="TAEInfoTabs" style="width:auto;height:auto;" data-options="fit:false ">
            @*<div class="easyui-accordion" title="处理&通话记录" style="overflow:auto" data-options="fit:true">*@
            <div title="处理&通话记录" style="width: auto; height: 100%;" data-options="fit:true">
                <div id="AcceptAccordion" class="easyui-accordion" style="width: 99%; height: 50%;">
                    <table border="0" cellpadding="0" cellspacing="0" style="width: 96%; text-align: left; margin-left: 0px; margin-right: 0px; margin-top: 20px; margin-bottom: 10px;">
                        <tr style="height: 28px; ">
                            <td style="width:10%" align="right">
                                责任受理人：
                            </td>
                            <td>
                                <span id="Dispatcher" style="width:150px; "></span>
                            </td>
                            <td style="width: 10%" align="right">
                                受理类型：
                            </td>
                            <td>
                                <span id="AcceptType" style="width: 150px; color: blue"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                原&nbsp;因：
                            </td>
                            <td>
                                <span id="DetailReason" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height: 28px; ">
                            <td style="width:10%" align="right">
                                呼救电话：
                            </td>
                            <td>
                                <span id="AlarmTel" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                挂起时刻：
                            </td>
                            <td>
                                <span id="HangUpTime" style="width: 150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                电话振铃时刻：
                            </td>
                            <td>
                                <span id="RingTime" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height: 28px; ">
                            <td style="width: 10%" align="right">
                                开始受理时刻：
                            </td>
                            <td>
                                <span id="AcceptBeginTime" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                结束受理时刻：
                            </td>
                            <td>
                                <span id="AcceptEndTime" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                发送指令时刻：
                            </td>
                            <td>
                                <span id="CommandTime" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height: 28px; ">
                            <td style="width: 10%" align="right">
                                现场地址：
                            </td>
                            <td>
                                <span id="LocalAddr" style="width:250px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                现场地址类型：
                            </td>
                            <td>
                                <span id="LocalAddrType" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                中&nbsp;心：
                            </td>
                            <td><span id="ACCenterName" style="width:150px;"></span></td>
                        </tr>
                        <tr style="height: 28px;">
                            <td style="width: 10%" align="right">
                                送往地址：
                            </td>
                            <td>
                                <span id="SendAddr" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                送往地点类型：
                            </td>
                            <td>
                                <span id="SendAddrType" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right"></td>
                            <td></td>
                        </tr>
                        <tr style="height: 28px; ">
                            <td style="width: 10%" align="right">
                                等车地址：
                            </td>
                            <td>
                                <span id="WaitAddr" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                患者姓名：
                            </td>
                            <td>
                                <span id="PatientName" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                性&nbsp;别：
                            </td>
                            <td>
                                <span id="Sex" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height: 28px; ">
                            <td style="width: 10%" align="right">
                                年&nbsp;龄：
                            </td>
                            <td>
                                <span id="Age" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                国&nbsp;籍：
                            </td>
                            <td>
                                <span id="National" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                @*民&nbsp;族：*@
                            </td>
                            <td>
                                @*<span id="Folk" style="width:150px;"></span>*@
                            </td>
                        </tr>
                        <tr style="height: 28px;">
                            <td style="width: 10%" align="right">
                                主&nbsp;诉：
                            </td>
                            <td>
                                <span id="AlarmReason" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                病&nbsp;情：
                            </td>
                            <td>
                                <span id="IllState" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                病种判断：
                            </td>
                            <td>
                                <span id="Judge" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height: 28px;">
                            <td style="width: 10%" align="right">
                                联系人：
                            </td>
                            <td>
                                <span id="LinkMan" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                联系电话：
                            </td>
                            <td>
                                <span id="LinkTel" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                分&nbsp;机：
                            </td>
                            <td>
                                <span id="Extension" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height: 28px; ">
                            <td style="width: 10%" align="right">
                                患者人数：
                            </td>
                            <td>
                                <span id="PatientCount" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                @*是否需要担架：*@
                            </td>
                            <td>
                                @*<span id="IsNeedLitter" style="width:150px;"></span>*@
                            </td>
                            <td style="width: 10%" align="right">
                                特殊要求：
                            </td>
                            <td>
                                <span id="SpecialNeed" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height: 28px; ">
                            <td style="width: 10%" align="right">
                                是否标注：
                            </td>
                            <td>
                                <span id="ACIsLabel" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                X,Y坐标：
                            </td>
                            <td>
                                <span id="ACXYPosition" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right"></td>
                            <td></td>
                        </tr>
                    </table>
                </div>
                <div class="easyui-panel" title="待命车辆列表" style="width: 99%; height: 160px; background-color: #DBF2F8; word-break: break-all; word-wrap: break-word; " data-options="collapsible:true">
                    <p id="SendAmbulanceList" style="font-size:small; text-align: center"></p>
                </div>
                <div class="easyui-panel" title="备注" style="width: 99%; height: 120px;" data-options="collapsible:true">
                    <p id="ACRemark" style="font-size:small"></p>
                </div>
                @*修改受理信息 2016-10-28*@
                <div id="AcceptEdit">
                    <div class="easyui-panel" title="修改受理信息" style="width: 99%; height: 120px; margin-left: auto; margin-right: auto;">
                        <table border="0" style=" width: 99%; margin-top: 5px; font-size: small">
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    主诉：
                                </td>
                                <td width="15%">
                                    <input id="EAlarmReason" class="easyui-textbox" style="width:300px" />
                                </td>
                                <td align="right" width="10%">
                                    @*是否需要担架：*@
                                </td>
                                <td width="15%">
                                    @*<select class="easyui-combobox" style="width: 150px" id="EIsNeedLitter" data-options="required:true,panelHeight:70, editable:false">
                                            <option value="1">需要</option>
                                            <option value="0">不需要</option>
                                        </select>*@
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    患者姓名：
                                </td>
                                <td width="15%">
                                    <input id="EPatientName" class="easyui-textbox" style="width:150px" />
                                </td>
                                <td align="right" width="10%">
                                    性别：
                                </td>
                                <td width="15%">
                                    <select class="easyui-combobox" style="width: 150px" id="ESex" data-options="required:false,panelHeight:70, editable:false">
                                        <option value="男">男</option>
                                        <option value="女">女</option>
                                    </select>
                                </td>
                                <td align="right" width="10%">
                                    年龄：
                                </td>
                                <td width="15%">
                                    <input id="EAge" class="easyui-combobox" style="width:150px" />
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    国籍：
                                </td>
                                <td width="15%">
                                    <input id="ENational" class="easyui-combobox" style="width:150px" />
                                </td>
                                <td align="right" width="10%">
                                    @*民族：*@
                                </td>
                                <td width="15%">
                                    @*<input id="EFolk" class="easyui-combobox" style="width:150px" />*@
                                </td>
                                <td align="right" width="10%">
                                    病种判断：
                                </td>
                                <td width="15%">
                                    <input id="EJudge" class="easyui-textbox" style="width:150px" />
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    联系人：
                                </td>
                                <td width="15%">
                                    <input id="ELinkMan" class="easyui-textbox" style="width:150px" />
                                </td>
                                <td align="right" width="10%">
                                    联系电话：
                                </td>
                                <td width="15%">
                                    <input id="ELinkTel" class="easyui-textbox" style="width:150px" />
                                </td>
                                <td align="right" width="10%">
                                    分机：
                                </td>
                                <td width="15%">
                                    <input id="EExtension" class="easyui-textbox" style="width:150px" />
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    现场地址：
                                </td>
                                <td width="15%">
                                    <input id="ELocalAddr" class="easyui-textbox" style="width:400px" />
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    等车地址：
                                </td>
                                <td width="15%">
                                    <input id="EWaitAddr" class="easyui-textbox" style="width:400px" />
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    送往地点：
                                </td>
                                <td width="15%">
                                    <input id="ESendAddr" class="easyui-textbox" style="width:400px" />
                                </td>
                                <td align="right" colspan="2">
                                    <a id="SaveAccept" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="submitAcceptEditForm()">保存修改</a>
                                    <a id="ViewAccept" class="easyui-linkbutton" data-options="iconCls:'icon-search'" href="javascript:void(0)" onclick="ViewAcceptModify()">查看修改</a>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            @*</div>*@
            @*受理详细信息*@
            <div title="事件详细信息" style="width: auto; height: 100%;" data-options="fit:true">
                <div id="EventAccordion" class="easyui-accordion" style="width: 99%; height: 360px;">
                    <table border="0" cellpadding="0" cellspacing="0" style="width: 96%;  text-align: left; margin-left: 0px; margin-right: 0px;margin-top:20px;margin-bottom:10px">
                        <tr style="height: 28px; ">
                            <td style="width: 10%" align="right">
                                事件编码：
                            </td>
                            <td>
                                <span id="EventCode" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                表单完成标志：
                            </td>
                            <td>
                                <span id="IsFinish" style="width:150px;"></span>
                            </td>
                            <td style="width: 10%" align="right">
                                是否落单：
                            </td>
                            <td>
                                <span id="IsPlaceOrder" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">事件类型：</td>
                            <td>
                                <span id="EventType" style="width: 200px; color: blue;"></span>
                            </td>
                            <td align="right">
                                事件名称：
                            </td>
                            <td>
                                <span id="EvetnName" style="width:150px;"></span>
                            </td>
                            <td align="right">受理中心：</td>
                            <td>
                                <span id="CenterName" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">事件来源：</td>
                            <td>
                                <span id="EventSource" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                首次呼救电话：
                            </td>
                            <td>
                                <span id="FirstAlarmCall" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                是否测试：
                            </td>
                            <td>
                                <span id="IsTest" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">
                                首次受理时刻：
                            </td>
                            <td>
                                <span id="FirstAcceptTime" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                首次受理调度：
                            </td>
                            <td>
                                <span id="FirstDisptcherName" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                受理次数：
                            </td>
                            <td>
                                <span id="AcceptCount" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">
                                首次派车时刻：
                            </td>
                            <td>
                                <span id="FirstSendAmbTime" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                执行任务总数：
                            </td>
                            <td>
                                <span id="TransactTaskCount" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                撤销受理数：
                            </td>
                            <td>
                                <span id="CancelAcceptCount" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">
                                占用台号：
                            </td>
                            <td>
                                <span id="TieUpDeskCode" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                中止任务数：
                            </td>
                            <td>
                                <span id="BreakTaskCount" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                病&nbsp;情：
                            </td>
                            <td>
                                <span id="IllState" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">
                                是否挂起：
                            </td>
                            <td>
                                <span id="IsHangUp" style="width:150px;"></span>
                            </td>
                            <td align="right">当前执行任务数：</td>
                            <td>
                                <span id="NonceTransactTaskCount" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                区&nbsp;域：
                            </td>
                            <td>
                                <span id="Area" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">
                                挂起时刻：
                            </td>
                            <td>
                                <span id="HangUpTime" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                X，Y坐标：
                            </td>
                            <td>
                                <span id="XYPosition" style="width:150px;"></span>
                            </td>
                            <td align="right">
                                是否标注：
                            </td>
                            <td>
                                <span id="IsLabel" style="width:150px;"></span>
                            </td>
                        </tr>
                        <tr style="height:28px;">
                            <td align="right">
                                预约时刻：
                            </td>
                            <td>
                                <span id="BespeakTime" style="width:150px;"></span>
                            </td>
                            <td align="right">事故类型：</td>
                            <td>
                                <span id="AccidentType" style="width:150px;"></span>
                            </td>
                            <td align="right">事故等级：</td>
                            <td>
                                <span id="AccidentLevel" style="width:150px;"></span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="easyui-panel" title="电话信息" style="width: 99%; height: 215px;" data-options="collapsible:true">
                    <table border="1" id="telRecord" style="margin-top: 5px"></table>
                </div>
                @*zzm*@
                @*修改事件信息 2016-10-24*@
                <div id="EventEdit">
                    <div class="easyui-panel" title="修改事件信息" style="width: 100%; height: 120px; margin-left: auto; margin-right: auto; ">
                        <table border="0" style="width: 99%; margin-top: 5px;font-size: small; ">
                            <tr style="height: 22px; ">
                                <td align="right">
                                    事件名称：
                                </td>
                                <td>
                                    <input id="EEvetnName" class="easyui-textbox" style="width:300px" />
                                </td>
                                <td align="right" width="10%">
                                    区域：
                                </td>
                                <td width="15%">
                                    <input id="EArea" class="easyui-combobox" style="width:150px" />
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" width="10%">
                                    事件来源：
                                </td>
                                <td width="15%">
                                    <input id="EEventSourceCode" class="easyui-combobox" style="width:150px" />
                                </td>
                                <td align="right" width="10%">
                                    事故等级：
                                </td>
                                <td width="15%">
                                    <input id="EAccidentLevelCode" class="easyui-combobox" style="width:150px" />
                                </td>
                                <td align="right" width="10%">
                                    事故类型：
                                </td>
                                <td width="15%">
                                    <input id="EAccidentTypeCode" class="easyui-combobox" style="width:150px" />
                                </td>
                            </tr>
                            <tr style="height: 22px; ">
                                <td align="right" colspan="2">
                                    <a id="Save" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="submitEditForm()">保存修改</a>
                                    <a id="View" class="easyui-linkbutton" data-options="iconCls:'icon-search'" href="javascript:void(0)" onclick="ViewEventModify()">查看修改</a>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>   @*事件详细信息*@

            <div title="任务&车辆详细信息" id="TaskDetialDIV" style="width: auto; height: auto;">
                <div id="TaskAccordion" class="easyui-accordion" style="width: 99%; height: 100%; ">
                </div>
            </div>
        </div>
    </div>
    <div id="LookCrack" class="easyui-window" data-options="title:'修改记录',iconCls:'icon-save',closed:true,modal:true,collapsible: false,maximizable: false" style="width: 850px; height: 550px; padding: 5px;">
        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'center',border:false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                <div data-options="region:'center'" style="background: #fafafa; overflow: hidden">
                    <table id="CrackList" class="easyui-datagrid"></table>
                </div>
            </div>
            <div data-options="region:'south',border:false" style="text-align: right; padding: 5px 0;">
                <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="closeDialogLookCrack()">关闭窗口</a>
            </div>
        </div>
    </div>@*修改记录*@
</form>
